﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using NutriLeaf.Web.Model;


namespace NutriLeaf.Services.Core.Tips
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "TipService" in code, svc and config file together.
    public class TipService : ITipService
    {
        public void InsertTip(Tip tip)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            NutriLeaf.Web.Core.Tips.Tips.InsertTip(tip, ref context);
        }
        public void InsertTipByCategory(Tip tip, TipCategory tipCategory)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTip(tip, tipCategory, ref context);

        }
        public void InsertTipByCategoryID(Tip tip, int tipCategoryId)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            NutriLeaf.Web.Core.Tips.Tips.InsertTip(tip, tipCategoryId, ref context);
        }

        public void InsertTipByCategoryAndUserID(Tip tip, TipCategory tipCategory, int userId)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTip(tip, tipCategory, userId, ref context);
        }

        public void ApproveTip(Tip tip)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            NutriLeaf.Web.Core.Tips.Tips.ApproveTip(tip, ref context);

        }

        public void ApproveTips(List<NutriLeaf.Web.Model.Tip> tip)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            NutriLeaf.Web.Core.Tips.Tips.ApproveTip(tip, ref context);
        }

        public void InsertTipCategory(TipCategory tipCategory)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
           
            NutriLeaf.Web.Core.Tips.Tips.InsertTipCategory(tipCategory, ref context);
        }

        public void InsertTipCategoryByParentCategory(TipCategory tipCategory, TipCategory parentTipCategory)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipCategegory(tipCategory, parentTipCategory, ref context);

        }

        public void InsertTipCategoryByParentCategoryID(TipCategory category, int parentCategoryId)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipCategory(category, parentCategoryId, ref context);
        }

        public void InsertTipCategoryByDetails(string categoryName, string categoryDescription, int ParentCategoryID)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipCategory(categoryName, categoryDescription, ParentCategoryID, ref context);
        }

        public void InsertTipCategoryByName(string categoryName, string categoryDescription)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipCategory(categoryName, categoryDescription, ref context);
        }

        public void InsertTipViewed(TipViewed tipViewed)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipViewed(tipViewed, ref context);
        }

        public void InsertTipViewedByUser(Tip tip, User user)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipViewed(tip, user, ref context);
        }

        public void InsertTipViewedByUserID(int tipId, int userId)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            
            NutriLeaf.Web.Core.Tips.Tips.InsertTipViewed(tipId, userId, ref context);
        }

        public bool IsTipApprovedByTipID(int tipId)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Tips.Tips.IsTipApproved(tipId, ref context);
        }

        public bool IsTipApprovedByTip(Tip tip)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Tips.Tips.IsTipApproved(tip, ref context);
        }

        public List<Tip> GetMostPopularTips(int categoryId,int count, int skip)
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Tips.Tips.GetMostPopularTips(categoryId,count, skip, ref context);
        }

        public List<NutriLeaf.Web.Model.TipCategory> GetAllTipCategories()
        {
            NutriLeafDBEntities context = new NutriLeafDBEntities();
            return NutriLeaf.Web.Core.Tips.Tips.GetAllTipCategory(ref context);
        }
    }
}
